package com.ymatou.iapi.trading.sellerquery2.service;

import org.json.JSONObject;

import com.ymatou.query.seller.trading.api.parameter.GetSellerSalesDetailResponseV2;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;

/**
 * @date 2016-09-08
 * @desc 获取卖家销售额明细
 * 
 * @author songyefeng
 *
 */
public class GetSellerSalesDetailV2Call extends YmatouBaseCall {
	private static String opurl = "api/App/GetSellerSalesDetailV2";

	public GetSellerSalesDetailV2Call() {
		super(EnvSetup.getSystemUrl("sellerquery2_iapi"), opurl, "GET", "PARAM");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept",
				"text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取BCode
	 * 
	 * @return
	 */
	public String getBCode() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("bcode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public JSONObject getData() {
		JSONObject Data = null;
		try {
			Data = new JSONObject(getReturnData()).getJSONObject("data");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public GetSellerSalesDetailResponseV2 getSellerSalesDetailResponseV2() {
		GetSellerSalesDetailResponseV2 Data = null;
		try {
			Data = (GetSellerSalesDetailResponseV2) FormatUtil
					.GSONToObject(
							DataUtil.Json.parseJsonObj(getData().toString())
									.toString(),
							GetSellerSalesDetailResponseV2.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}
}
